package com.wlient.basic.Stream;

import java.util.*;
import java.util.stream.Collectors;

public class MaxByMinByExample {
    public static void main(String[] args) {
        List<Integer> list = Arrays.asList(30, 10, 20, 35);
        Double num = list.stream().collect(Collectors.averagingDouble(i->i));
        System.out.println(num);
        Long i = list.stream().collect(Collectors.counting());
        System.out.println(i);
        Map<Integer, Integer> map = list.stream().collect(Collectors.toMap(k->k, v->v+v));

        Iterator<Map.Entry<Integer,Integer>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<Integer,Integer> entry = iterator.next();
            System.out.println("key:"+entry.getKey());
            System.out.println("value:"+entry.getValue());
        }
        map.forEach((k,v)-> System.out.println(v));
    }

}